#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/26 10:55
# @Author  : AshJo
# @Desc    : 装饰器函数classmethod
# @Filename: classmethod.py
# @Version : v1.0
"""
import time


class Goods:
    __discount = 0.8

    def __init__(self):
        self.__price = 5
        self.price = self.__discount * self.__price

    @classmethod  # 把一个对象绑定的方法修改成一个 类方法
    def change_discount(cls, new_value):
        cls.__discount = new_value


class Date:
    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day

    @classmethod
    def today(cls):
        struct_t = time.localtime()
        date = cls(struct_t.tm_year, struct_t.tm_mon, struct_t.tm_mday)
        return date


Goods.change_discount(0.7)
apple = Goods()
print(apple.price)

d = Date.today()
print('%d-%d-%d' % (d.year, d.month, d.day))
